package com.example.demomk.Dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.demomk.entity.Location;

import java.util.List;

@Dao
public interface LocationDao {
    @Insert
    long insertLocation(Location location);

    @Update
    void updateLocation(Location location);

    @Delete
    void deleteLocation(Location location);

    @Query("SELECT * FROM locations ORDER BY location_name ASC")
    LiveData<List<Location>> getAllLocations();

    @Query("SELECT * FROM locations WHERE id = :locationId")
    LiveData<Location> getLocationById(int locationId);

    @Query("SELECT * FROM locations WHERE location_name LIKE :name LIMIT 1")
    Location findLocationByName(String name);
}
